package com.xmg.mgrsite.base;

import com.xmg.p2p.base.util.JSONResult;
import com.xmg.p2p.business.domain.PlatformBankinfo;
import com.xmg.p2p.business.query.PlatformBankinfoQueryObject;
import com.xmg.p2p.business.service.IPlatformBankinfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @BelongsProject: jinrong-website
 * @BelongsPackage: com.xmg.mgrsite.base
 * @author: Andy
 * @date: 2021.4.7 19:30
 * @Description: 平台用户相关的管理器
 * @since JDK 1.8
 */
@Controller
public class PlatformBankinfoController {
    @Autowired
    private IPlatformBankinfoService platformBankinfoService;

    //根据条件获取平台账号集合
    @RequestMapping("companyBank_list")
    public String BankList(@ModelAttribute("qo") PlatformBankinfoQueryObject qo, Model model){
        model.addAttribute("pageResult",this.platformBankinfoService.query(qo));
        return "platformbankinfo/list";
    }


    /**
     * 修改或保存
     * @param platformBankinfo
     * @return
     */
    @RequestMapping("companyBank_update")
    @ResponseBody
    public JSONResult saveOrUpdate(PlatformBankinfo platformBankinfo){
        JSONResult json = new JSONResult();
        try {
            this.platformBankinfoService.saveOrUpdate(platformBankinfo);
        } catch (Exception e) {
            e.printStackTrace() ;
            json.setSuccess(false);
            json.setMsg("添加失败！");
        }
        return json ;
    }
}
